package se.jagvetintedu;

import java.util.ArrayList;

public final class MyFunctions {
	
	public static ArrayList<Integer> findPrimeFactors(Long of) {
		prime primeGenerator = new prime();
		ArrayList<Integer> primeList;
		ArrayList<Integer> factorList;
		
		primeList = primeGenerator.generate((int) Math.sqrt(of));
		factorList = new ArrayList<Integer>();
		
		return fPF(of, primeList, factorList);
		
	}
	
	private static ArrayList<Integer> fPF(Long of, ArrayList<Integer> primeList, ArrayList<Integer> factorList) {
		for (Integer i : primeList) {
			if (of%i == 0) {
				factorList.add(i);
				fPF(of/i, primeList, factorList);
				break;
			}
		}
		
		return factorList;
		
	}
}
